import js from "@eslint/js";
import pluginVue from 'eslint-plugin-vue';
// importSort插件功能是：项目中引入插件的顺序必须先是官方，后是自己的插件
import importSort from 'eslint-plugin-simple-import-sort';
import vueEslintParser from 'vue-eslint-parser'
import globals from 'globals';

export default [
  {
    languageOptions:{
      globals:{
        ...globals.browser,
        computed:"readonly",
        defineEmits:"readonly",
        defineExpose:"readonly",
        defineProps:"readonly",
        onMounted:"readonly",
        onUnmounted:"readonly",
        reactive:"readonly",
        ref:"readonly",
        shallowReactive:"readonly",
        shallowRef:"readonly",
        toRef:"readonly",
        toRefs:"readonly",
        watch:"readonly",
        watchEffect:"readonly"
      }
    }
  },
  {
    files:["**/*,.{ts,tsx,vue}"],
    ignores:[],
    rules: {
      ...js.configs.recommended.rules,
      ...pluginVue.configs['flat/recommended'].rules,
      "no-console":'error',
      'no-debugger':"error",
      "vue/valid-define-emits":"error",
      "simple-import-sort/imports":"error",
      "simple-import-sort/exports":"error"
    },
    languageOptions:{
      parser: vueEslintParser,
      parserOptions: {
        ecmaFeatures:{
          jsx:true
        },
        extraFileExtensions:[".vue"]
      }
    },
    // eslint 9.x 版本的插件注册方式
    plugins:{
      vue: pluginVue,
      "simple-import-sort":importSort
    }
  }
];